﻿#region

using System;
using System.Collections.Generic;

#endregion

namespace Core.SQLBuilder
{
    public class WhereClause
    {
        private List<SQLClause> list = new List<SQLClause>();

        public List<SQLClause> List
        {
            get { return list; }
            set { list = value; }
        }

        public void Add(SQLClause clause)
        {
            list.Add(clause);
        }

        public string ToSQL()
        {
            if (list.Count < 1)
            {
                return String.Empty;
            }
            var query = "Where ";
            for (var i = 0; i < list.Count; i++)
            {
                if (i == 0)
                {
                    query += " " + list[i].ToSQL();
                }
                else
                {
                    query += " OR " + list[i].ToSQL();
                }
            }
            return query;
        }
    }
}